package com.ruoyi.business.alarm.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.alarm.domain.DoorAlarmLog;
import com.ruoyi.business.alarm.service.IDoorAlarmLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 门报警日志Controller
 * 
 * @author ruoyi
 * @date 2024-01-01
 */
@RestController
@RequestMapping("/business/alarm")
public class DoorAlarmLogController extends BaseController
{
    @Autowired
    private IDoorAlarmLogService doorAlarmLogService;

    /**
     * 查询门报警日志列表
     */
    @PreAuthorize("@ss.hasPermi('business:alarm:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoorAlarmLog doorAlarmLog)
    {
        startPage();
        List<DoorAlarmLog> list = doorAlarmLogService.selectDoorAlarmLogList(doorAlarmLog);
        return getDataTable(list);
    }

    /**
     * 导出门报警日志列表
     */
    @PreAuthorize("@ss.hasPermi('business:alarm:export')")
    @Log(title = "门报警日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DoorAlarmLog doorAlarmLog)
    {
        List<DoorAlarmLog> list = doorAlarmLogService.selectDoorAlarmLogList(doorAlarmLog);
        ExcelUtil<DoorAlarmLog> util = new ExcelUtil<DoorAlarmLog>(DoorAlarmLog.class);
        util.exportExcel(response, list, "门报警日志数据");
    }

    /**
     * 获取门报警日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:alarm:query')")
    @GetMapping(value = "/{alarmId}")
    public AjaxResult getInfo(@PathVariable("alarmId") Long alarmId)
    {
        return success(doorAlarmLogService.selectDoorAlarmLogByAlarmId(alarmId));
    }

    /**
     * 删除门报警日志
     */
    @PreAuthorize("@ss.hasPermi('business:alarm:remove')")
    @Log(title = "门报警日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{alarmIds}")
    public AjaxResult remove(@PathVariable Long[] alarmIds)
    {
        return toAjax(doorAlarmLogService.deleteDoorAlarmLogByAlarmIds(alarmIds));
    }
}

